﻿@using Abc.Core;
@using Abc.Application;
@{
    ViewData["Title"] = "RSA";
}

<section class="panel panel-padding">
    <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">

        <form class="layui-form" action="">
            <table class="layui-table">
                <tbody>
                    <tr>
                        <td>公钥</td>
                        <td><textarea class="lay-textarea" id="publicKey" name="publicKey" style="height:200px;min-width:400px;"></textarea></td>

                        <td>私钥</td>
                        <td><textarea class="lay-textarea" id="privateKey" name="privateKey" style="height:200px;min-width:400px;"></textarea></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <div class="layui-btn submitbtn" lay-submit lay-filter="submit">提交数据</div>
                            <div class="layui-btn submitbtn" lay-submit lay-filter="clear">清理换行符</div>
                        </td>
                    </tr>
                    <tr>
                        <td>公钥-精简压缩</td>
                        <td><textarea class="lay-textarea" id="publicKey2" name="publicKey2" style="height:200px;min-width:400px;"></textarea></td>

                        <td>私钥-精简压缩</td>
                        <td><textarea class="lay-textarea" id="privateKey2" name="privateKey2" style="height:200px;min-width:400px;"></textarea></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <div class="layui-btn submitbtn" lay-submit lay-filter="submit2">提交数据</div>
                        </td>
                    </tr>
                </tbody>
            </table>

        </form>
    </div>
</section>

@*<script src="~/lib/ckeditor4/ckeditor.js"></script>*@
@section Scripts{
    <script>
        layui.define(['element', 'jquery', 'form'], function () {
            let $ = layui.jquery;
            let form = layui.form;
            let element = layui.element;
            let dtree = layui.dtree;

            //Info 初始化
            abc.infoInit();
            //提交
            form.on('submit(submit)', function (obj) {
                abc.post({
                    url: '@(Url.Action("RsaVer"))'
                    , data: { publicKey: obj.field.publicKey, privateKey: obj.field.privateKey }

                });

                return false;
            });
             form.on('submit(clear)', function (obj) {
                var privateKey2 = $("#privateKey").val().replace(/\r|\n/ig,"");
                $("#privateKey2").val(privateKey2);

                var publicKey2 = $("#publicKey").val().replace(/\r|\n/ig, "");
                $("#publicKey2").val(publicKey2);

                return false;
            });

            form.on('submit(submit2)', function (obj) {
                abc.post({
                    url: '@(Url.Action("RsaVer"))'
                    , data: { publicKey: obj.field.publicKey2, privateKey: obj.field.privateKey2 }

                });

                return false;
            });

        });
    </script>
}
